<template>
  <div>
    <div class="swipe-wrapper">
      <van-swipe :autoplay="5000">
        <van-swipe-item
          class="item"
          v-for="(item, index) in banner"
          :key="index"
          :show-indicators="false"
        >
          <img :src="item" @click="goTo(item.url)" :href="item.url" ref="img"/>
        </van-swipe-item>
      </van-swipe>
    </div>
  </div>
</template>

<script type="text/ecmascript-6">
  export default {
    name: 'banner',
    props: {
      banner: {
        type: Array
      }
    },
    data() {
      return {
        url: ''
      };
    },
    created() {
    },
    methods: {
      goTo(e) {
        if (e && e !== '') {
          window.location.href = e;
        }
      }
    }
  };
</script>

<style lang="stylus" rel="stylesheet/stylus" scoped>
  @import "../../assets/stylus/main.styl"
  .van-swipe-item {
    float: left;
    height: auto;
  }

  img[lazy=loading] {
    width: 30vw;
    margin 8vw auto
  }

  .swipe-wrapper {
    width: 100vw;
    height 67vw
  }

  .item {
    text-align center

    & img {
      width: 100vw;
      -webkit-touch-callout behavior !important
      -webkit-user-select text !important
    }
  }

  >>> .van-swipe__indicators {
    display none
  }
</style>
